package hotel.switchs.oversea.biz.controller;

import com.alibaba.fastjson.JSONObject;
import hotel.base.oversea.utils.Result;
import hotel.switchs.oversea.biz.service.SwitchOrderListNotifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 平台携程订单实时状态池
 * 将携程取到所有订单存储该表
 * 取消，下单都从该表操作(SwitchOrderPool)表控制层
 *
 * @author HuangT
 * @since 2020-07-07 09:58:09
 */
@RestController
@Slf4j
@RequestMapping("/switchOrderListNotify")
@Api(value = "SwitchOrderListNotifyController", tags = {"平台携程通知订单"})
public class SwitchOrderListNotifyController {

    @Resource
    private SwitchOrderListNotifyService switchOrderListNotifyService;

    @PostMapping("/queryOneNotDealByNotifyOrderId")
    @ApiOperation(value = "返回一条未处理的通知订单的id",notes="必须经过auth授权")
    public Result<Object> queryOneNotDealByNotifyOrderId(){//实际返回mdKey
        return switchOrderListNotifyService.queryOneNotDealByNotifyOrderId();
    }

    @PostMapping("/updateNotifyOrderIsDeal")
    @ApiOperation(value = "更新通知订单的是否被处理状态",notes="必须经过auth授权")
    public Result<Object> updateCompanreMasterIsCreateSub(@RequestBody JSONObject jsonObject){
        String id = jsonObject.getString("id");//约定为id为字段md5Key
        Integer isDeal = jsonObject.getInteger("isDeal");
        String isDealRemark = jsonObject.getString("isDealRemark");
        return switchOrderListNotifyService.updateNotifyOrderIsDeal(id,isDeal,isDealRemark);
    }
}
